home *** CD-ROM | disk | FTP | other *** search
Text File | 2006-05-31 | 63.3 KB | 2,346 lines |
- function getNetDebugVersion()
- {
- return 1;
- }
- function NetDebugConfig()
- {
- }
- function attachNetDebugConfigFunctions(ndc)
- {
- ndc.setDebug = function(setval)
- {
- this.m_debug = setval;
- };
- ndc.getDebug = function()
- {
- return this.m_debug;
- };
- for(var prop in ndc)
- {
- if(typeof ndc[prop] == "object")
- {
- attachNetDebugConfigFunctions(ndc[prop]);
- }
- }
- }
- function getDefaultNetDebugConfig(iscontroller)
- {
- if(_global.netDebugConfigSO == undefined)
- {
- var soName = "TestMovie_Config_Info";
- if(iscontroller)
- {
- soName = "Controller_Config_Info";
- }
- _global.netDebugConfigSO = SharedObject.getLocal(soName);
- }
- if(_global.netDebugConfigSO.data.config == undefined)
- {
- _global.netDebugConfigSO.data.config = getRealDefaultNetDebugConfig();
- }
- _global.netDebugConfigSO.flush();
- return _global.netDebugConfigSO.data.config;
- }
- function getRealDefaultNetDebugConfig()
- {
- var defaultConfig = new NetDebugConfig();
- defaultConfig.m_debug = true;
- defaultConfig.client = new NetDebugConfig();
- defaultConfig.client.m_debug = true;
- defaultConfig.client.trace = true;
- defaultConfig.client.recordset = true;
- defaultConfig.client.http = true;
- defaultConfig.client.rtmp = true;
- defaultConfig.realtime_server = new NetDebugConfig();
- defaultConfig.realtime_server.m_debug = true;
- defaultConfig.realtime_server.trace = true;
- defaultConfig.app_server = new NetDebugConfig();
- defaultConfig.app_server.m_debug = true;
- defaultConfig.app_server.trace = true;
- defaultConfig.app_server.error = true;
- defaultConfig.app_server.recordset = true;
- defaultConfig.app_server.httpheaders = false;
- defaultConfig.app_server.amf = false;
- defaultConfig.app_server.amfheaders = false;
- defaultConfig.app_server.coldfusion = true;
- return defaultConfig;
- }
- function NetDebugEvent()
- {
- }
- function NetDebugErrorEvent(dataobj)
- {
- this.init();
- this.EventType = "NetDebugError";
- this.Error = dataobj;
- }
- function NetDebugTraceEvent(traceobj)
- {
- this.init();
- this.EventType = "Trace";
- this.Trace = traceobj;
- }
- function NetDebugTraceNetServicesEvent(w, s, n, m)
- {
- this.init();
- this.EventType = "NetServicesTrace";
- this.Trace = m;
- this.Who = w;
- this.Severity = s;
- this.Number = n;
- }
- function NetDebugNCEvent()
- {
- }
- function NetDebugResultEvent(resultobj)
- {
- this.init();
- this.EventType = "Result";
- this.Result = resultobj;
- }
- function NetDebugStatusEvent(statusobj)
- {
- this.init();
- this.EventType = "Status";
- this.Status = statusobj;
- }
- function NetDebugConnectEvent(args)
- {
- this.init();
- this.EventType = "Connect";
- this.ConnectString = args[0];
- if(args[1] != null)
- {
- this.UserName = args[1];
- }
- if(args[2] != null)
- {
- this.Password = args[2];
- }
- }
- function NetDebugCallEvent(args)
- {
- this.init();
- this.EventType = "Call";
- this.MethodName = args[0];
- this.Parameters = new Array();
- var i = 2;
- while(i < args.length)
- {
- this.Parameters[i - 2] = args[i];
- i++;
- }
- }
- function NetDebugCloseEvent()
- {
- this.init();
- this.EventType = "Close";
- }
- function NetDebugAddHeaderEvent(args)
- {
- this.init();
- this.EventType = "AddHeader";
- this.HeaderName = args[0];
- this.MustUnderstand = args[1];
- if(args[2] != null)
- {
- this.HeaderObject = args[2];
- }
- }
- function NetDebugRtmpLogEvent(infoobj)
- {
- this.initDate();
- this.EventType = "Trace";
- this.Source = "Flash Communication Server";
- this.Info = infoobj;
- this.Trace = infoobj.description;
- }
- function NetDebugDuplicateNCDErrorEvent()
- {
- this.initDate();
- this.EventType = "Error";
- this.Source = "NCD";
- this.Message = "NCD_ALREADY_RUNNING";
- }
- function NetDebugFailedSendErrorEvent(ev)
- {
- this.initDate();
- this.EventType = "Error";
- this.Source = "NCD";
- this.OriginalEvent = ev;
- this.Message = "NCD_FAILED_TO_SEND_EVENT";
- }
- function NetDebugInfoErrorEvent(infoobj, mes)
- {
- this.initDate();
- this.EventType = "Error";
- this.Source = "NCD";
- this.Info = infoobj;
- if(mes != null)
- {
- this.Message = mes;
- }
- }
- function NetDebugReceiveCallEvent(mName, args)
- {
- this.init();
- this.EventType = "ReceivedCall";
- this.MethodName = mName;
- this.Parameters = args;
- }
- function netDebugProxyConnect()
- {
- this.attachDebug();
- var proto = arguments[0].substr(0,4);
- if(proto == "http" || proto == "rtmp")
- {
- this.m_Protocol = proto;
- }
- else
- {
- this.m_Protocol = "http";
- }
- this.sendClientEvent(new NetDebugConnectEvent(arguments));
- if(this.isRealTime())
- {
- this.m_ConnectString = arguments[0];
- getNetDebug().sendCommand(new StartRTMPTraceCommand(arguments[0]));
- var ret = this.realconnect.apply(this,arguments);
- this.realcall("@getClientID",new RTMPClientIDResponse(arguments[0],this));
- return ret;
- }
- return this.realconnect.apply(this,arguments);
- }
- function netDebugProxyCall()
- {
- this.attachDebug();
- this.sendClientEvent(new NetDebugCallEvent(arguments));
- this.addNetDebugHeader();
- if(this.m_Config.app_server)
- {
- arguments[1] = new NetDebugResponseProxy(this,arguments[1]);
- return this.realcall.apply(this,arguments);
- }
- return this.realcall.apply(this,arguments);
- }
- function netDebugProxyClose()
- {
- this.attachDebug();
- this.sendClientEvent(new NetDebugCloseEvent());
- if(this.isRealTime())
- {
- getNetDebug().sendCommand(new StopRTMPTraceCommand(this.m_ConnectString,this.m_ClientId));
- }
- var ret = this.realclose();
- getNetDebug().removeNetConnection(this);
- return ret;
- }
- function netDebugProxyAddHeader()
- {
- this.attachDebug();
- this.sendClientEvent(new NetDebugAddHeaderEvent(arguments));
- return this.realaddHeader.apply(this,arguments);
- }
- function RTMPClientIDResponse(cs, nc)
- {
- this.m_ConnectString = cs;
- this.m_NC = nc;
- }
- function NetDebugResponseProxy(source, original)
- {
- this.m_SourceNC = source;
- this.m_OriginalNR = original;
- }
- function GlobalLocalConnection(iscontroller, receiver, domainname)
- {
- this.maxConnections = 10;
- var sToMovie = "_NetDebugLocalToDebugMovie";
- var sToController = "_NetDebugLocalToController";
- var connectname = null;
- if(iscontroller)
- {
- connectname = sToController;
- this.sendnames = new Array();
- this.sendnames.push(sToMovie);
- var i = 0;
- while(i < this.maxConnections)
- {
- this.sendnames.push(sToMovie + i);
- i++;
- }
- this.maxConnections = 0;
- }
- else
- {
- connectname = sToMovie;
- this.sendnames = new Array();
- this.sendnames.push(sToController);
- }
- this.setDomainName(domainname);
- if(_global.g_NetDebugLocalConnection == undefined)
- {
- _global.g_NetDebugLocalConnection = new LocalConnection();
- _global.g_NetDebugLocalConnection.allowDomain = function()
- {
- return true;
- };
- }
- if(receiver != null)
- {
- _global.g_NetDebugLocalConnection.m_Receiver = receiver;
- _global.g_NetDebugLocalConnection.onData = function(dataobj)
- {
- _global.g_NetDebugLocalConnection.m_Receiver.onReceive(dataobj);
- };
- _global.g_NetDebugLocalConnection.onCommand = function(commandobj)
- {
- _global.g_NetDebugLocalConnection.m_Receiver.onReceiveCommand(commandobj);
- };
- if(!_global.g_NetDebugLocalConnection.connect(connectname))
- {
- var connected = false;
- var i = 0;
- while(i < this.maxConnections)
- {
- if(_global.g_NetDebugLocalConnection.connect(connectname + i))
- {
- connected = true;
- break;
- }
- i++;
- }
- if(!connected)
- {
- if(iscontroller)
- {
- receiver.onReceiveError(new NetDebugDuplicateNCDErrorEvent());
- }
- }
- }
- }
- }
- function LocalCommand()
- {
- }
- function UpdateNetDebugConfigCommand(dataobj)
- {
- this.init("updateConfig",dataobj);
- }
- function GetConfigCommand()
- {
- this.init("getConfig",null);
- }
- function StartRTMPTraceCommand(cs)
- {
- var connectinfo = new Object();
- connectinfo.connectstring = cs;
- connectinfo.url = _root._url;
- this.init("startRealTimeTrace",connectinfo);
- }
- function AddRTMPClientCommand(cs, cid)
- {
- var connectinfo = new Object();
- connectinfo.connectstring = cs;
- connectinfo.url = _root._url;
- connectinfo.clientid = cid;
- this.init("addRealTimeClient",connectinfo);
- }
- function StopRTMPTraceCommand(cs, cid)
- {
- var connectinfo = new Object();
- connectinfo.connectstring = cs;
- connectinfo.url = _root._url;
- connectinfo.clientid = cid;
- this.init("stopRealTimeTrace",connectinfo);
- }
- function NetDebug()
- {
- this.m_ncs = new Array();
- this.m_Config = getDefaultNetDebugConfig();
- this.m_glc = new GlobalLocalConnection(false,this);
- this.m_glc.sendCommand(new GetConfigCommand());
- this.m_NextNewId = 0;
- }
- function getNetDebug()
- {
- return _global.netDebugInstance;
- }
- function mAddGeneral(vSession, vPK, vStart, vEnd, vHeight, vWidth, vDepth, vPlatform)
- {
- aRecord = new Object();
- aRecord.session_ID = vSession;
- aRecord.pk_ID = vPK;
- aRecord.session_start = vStart;
- aRecord.session_end = vEnd;
- aRecord.screenheight = vHeight;
- aRecord.screenwidth = vWidth;
- aRecord.screendepth = vDepth;
- aRecord.platform = vPlatform;
- pGeneral_RS.push(aRecord);
- }
- function mAddSection(vMain, vFirst, vGallery, vSlideshow, vTrailer, vPoster, vLogos, vNotes, vSummary, vFlashpaper, vWebsite)
- {
- aRecord = new Object();
- aRecord.main = vMain;
- aRecord.first = vFirst;
- aRecord.gallery = vGallery;
- aRecord.slideshow = vSlideshow;
- aRecord.trailer = vTrailer;
- aRecord.poster = vPoster;
- aRecord.logos = vLogos;
- aRecord.notes = vNotes;
- aRecord.summary = vSummary;
- aRecord.flashpaper = vFlashpaper;
- aRecord.website = vWebsite;
- pSections_RS.push(aRecord);
- }
- function mAddSuperSectionOLD()
- {
- }
- function mAddSuperSection(vMovieTitle, vView)
- {
- aRecord = new Object();
- aRecord.movietitle = vMovieTitle;
- aRecord.viewdata = vView;
- pSuperSections_RS.push(aRecord);
- }
- function mAddDownLoads(vType, vName)
- {
- aRecord = new Object();
- aRecord.type = vType;
- aRecord.name = vName;
- pDownLoads_RS.push(aRecord);
- }
- function mAddImages(vName)
- {
- pImages_RS.push(vName);
- }
- function mAddFlashpaper(vName)
- {
- pFlashpaper_RS.push(vName);
- }
- function mSendToColdFusion()
- {
- pDebugResults = "";
- exposure.inserttrackingdata(pGeneral_RS,pSections_RS,pDownLoads_RS,pImages_RS);
- }
- function mSendSuperToColdFusion()
- {
- pDebugResults = "";
- exposure.insertsupertrackingdata(pGeneral_RS,pSuperSections_RS,pDownLoads_RS,pImages_RS,pFlashpaper_RS);
- }
- function mSendToColdFusion_Result(data)
- {
- trace("Data from mSendToColdFusion_Result : " + data);
- }
- function mSendSuperToColdFusion_Result(data)
- {
- trace("Data from mSendSuperToColdFusion_Result : " + data);
- }
- function mSendNewToColdFusion_Result(data)
- {
- trace("Data from mSendNewToColdFusion_Result : " + data);
- }
- function mSendNewToColdFusion()
- {
- trace("FLASH: pGeneral_RS: " + pGeneral_RS.toString());
- trace("FLASH: pSuperSections_RS: " + pSuperSections_RS.toString());
- trace("FLASH: pDownLoads_RS: " + pDownLoads_RS.toString());
- trace("FLASH: pImages_RS: " + pImages_RS.toString());
- trace("FLASH: pFlashpaper_RS: " + pFlashpaper_RS.toString());
- trace("FLASH: pSuperSections_RS[0]: " + this.pSuperSections_RS[0].movietitle.toString());
- trace("FLASH: pSuperSections_RS[1]: " + this.pSuperSections_RS[1].movietitle.toString());
- trace("FLASH: pSuperSections_RS[2]: " + this.pSuperSections_RS[2].movietitle.toString());
- trace("FLASH: pSuperSections_RS[3]: " + this.pSuperSections_RS[3].movietitle.toString());
- trace("FLASH: pSuperSections_RS[0]: " + this.pSuperSections_RS[0].viewdata.toString());
- trace("FLASH: pSuperSections_RS[1]: " + this.pSuperSections_RS[1].viewdata.toString());
- trace("FLASH: pSuperSections_RS[2]: " + this.pSuperSections_RS[2].viewdata.toString());
- trace("FLASH: pSuperSections_RS[3]: " + this.pSuperSections_RS[3].viewdata.toString());
- pDebugResults = "";
- exposure.insertnewtrackingdata(pGeneral_RS,pSections_RS,pDownLoads_RS,pImages_RS,pFlashpaper_RS);
- trace("FLASH: mSendNewToColdFusion executed");
- }
- function insertsupertrackingdata(result)
- {
- trace("FLASH: Results from coldfusion insertsupertrackingdata: " + result);
- pDebugResults = result;
- }
- function insertnewtrackingdata(result)
- {
- trace("FLASH: Results from coldfusion insertnewtrackingdata: " + result);
- pDebugResults = result;
- }
- function inserttrackingdata_Result(result)
- {
- trace("FLASH: Results from coldfusion inserttrackingdata_Result: " + result);
- pDebugResults = result;
- }
- function insertnewtrackingdata_Result(result)
- {
- trace("FLASH: Results from coldfusion insertnewtrackingdata_Result: " + result);
- pDebugResults = result;
- }
- function mReport()
- {
- trace("FLASH: General RecordSet: " + pGeneral_RS.getColumnNames());
- trace("FLASH: Sections RecordSet: " + pSections_RS.getColumnNames());
- trace("FLASH: Super Sections RecordSet: " + pSuperSections_RS.getColumnNames());
- trace("FLASH: DownLoads RecordSet: " + pDownLoads_RS.getColumnNames());
- trace("FLASH: Images RecordSet: " + pImages_RS.getColumnNames());
- trace("FLASH: Flashpaper RecordSet: " + pFlashpaper_RS.getColumnNames());
- }
- function mReSetArrays()
- {
- pGeneral_RS = [];
- pSections_RS = [];
- pSuperSections_RS = [];
- pDownLoads_RS = [];
- pImages_RS = [];
- pFlashpaper_RS = [];
- trace("FLASH: Arrays have been reset: ");
- }
- stop();
- _global.copyProperties = function(to, from)
- {
- for(var prop in from)
- {
- if(!(prop == "__proto__" || prop == "function"))
- {
- if(typeof from[prop] == "object")
- {
- if(to[prop] == undefined)
- {
- to[prop] = new from[prop].__proto__.constructor();
- }
- copyProperties(to[prop],from[prop]);
- }
- else
- {
- to[prop] = from[prop];
- }
- }
- }
- };
- _global.copyObject = function(obj)
- {
- if(typeof obj == "object")
- {
- var ret = new obj.__proto__.constructor();
- copyProperties(ret,obj);
- return ret;
- }
- return obj;
- };
- _global.objectToStringTree = function(obj, openstr, typesepstr, valuesepstr, closestr)
- {
- var st = new StringLineAdder(obj,new TreeLineRenderer(openstr != null ? openstr : "{",typesepstr != null ? typesepstr : ":",valuesepstr != null ? valuesepstr : ", ",closestr != null ? closestr : "}"));
- return st.getString();
- };
- _global.objectToListboxTree = function(listbox, obj, openstr, typesepstr, valuesepstr, closestr)
- {
- new ListLineAdder(listbox,obj,new TreeLineRenderer(openstr != null ? openstr : "{",typesepstr != null ? typesepstr : ":",valuesepstr != null ? valuesepstr : ", ",closestr != null ? closestr : "}"));
- };
- _global.StringLineAdder = function(obj, renderer)
- {
- this.linerenderer = renderer;
- this.output = "";
- nestedObjectDump(0,null,obj,this);
- };
- StringLineAdder.prototype.getString = function()
- {
- return this.output;
- };
- StringLineAdder.prototype.addLine = function(level, objname, objtype, objvalue, objnum)
- {
- var line = this.linerenderer.getLine(level,objname,objtype,objvalue,objnum);
- if(line != null)
- {
- this.output += line + "\n";
- }
- return true;
- };
- _global.ListLineAdder = function(listbox, obj, renderer)
- {
- this.linerenderer = renderer;
- this.output_lb = listbox;
- nestedObjectDump(0,null,obj,this);
- };
- ListLineAdder.prototype.addLine = function(level, objname, objtype, objvalue, objnum)
- {
- var line = this.linerenderer.getLine(level,objname,objtype,objvalue,objnum);
- if(line != null)
- {
- this.output_lb.addItem(line);
- }
- return true;
- };
- _global.TreeLineRenderer = function(pre, typedelim, valuedelim, post)
- {
- this.init(pre,typedelim,valuedelim,post);
- };
- TreeLineRenderer.prototype.init = function(pre, typedelim, valuedelim, post)
- {
- this.prechar = pre;
- this.typechar = typedelim;
- this.valuechar = valuedelim;
- this.postchar = post;
- };
- TreeLineRenderer.prototype.getLine = function(level, objname, objtype, objvalue, objnum)
- {
- var sAdd = "";
- var i = 0;
- while(i < level)
- {
- sAdd += "\t";
- i++;
- }
- var valuedelim = this.valuechar;
- if(objname != null && objtype != "object")
- {
- sAdd += this.prechar + objtype + this.typechar + objname;
- }
- else if(objtype == "object")
- {
- if(typeof objvalue == "number")
- {
- sAdd += this.prechar + objtype + this.typechar + objname;
- sAdd += valuedelim + "object#" + objvalue;
- objvalue = null;
- }
- else
- {
- sAdd += this.prechar + objtype + "#" + objnum + this.typechar + objname;
- }
- }
- else
- {
- sAdd += this.prechar + objtype;
- valuedelim = this.typechar;
- }
- if(objvalue != null)
- {
- sAdd += valuedelim + objvalue;
- }
- sAdd += this.postchar;
- return sAdd;
- };
- _global.nestedObjectDump = function(level, objname, obj, lineadder)
- {
- if(level == 0)
- {
- nestedObjectDump.callcount = nestedObjectDump.callcount + 1;
- nestedObjectDump.objcount = -1;
- }
- if(obj == null)
- {
- return lineadder.addLine(level,objname,"undefined");
- }
- if(typeof obj == "function")
- {
- return lineadder.addLine(level,objname,"function");
- }
- if(typeof obj == "object")
- {
- if(obj.__nestedObjectDump_id != undefined && obj.__nestedObjectDump_ref == nestedObjectDump.callcount)
- {
- return lineadder.addLine(level,objname,"object",obj.__nestedObjectDump_id);
- }
- nestedObjectDump.objcount = nestedObjectDump.objcount + 1;
- if(lineadder.addLine(level,objname,"object",null,nestedObjectDump.objcount) == nestedObjectDump.skip)
- {
- return nestedObjectDump.proceed;
- }
- obj.__nestedObjectDump_id = nestedObjectDump.objcount;
- obj.__nestedObjectDump_ref = nestedObjectDump.callcount;
- var props = new Array();
- var objs = new Array();
- for(var prop in obj)
- {
- if(!(prop == "__proto__" || prop == "__nestedObjectDump_id" || prop == "__nestedObjectDump_ref"))
- {
- if(typeof obj[prop] == "object")
- {
- objs.push(prop);
- }
- else
- {
- props.push(prop);
- }
- }
- }
- if(objs.length == 0 && props.length == 0)
- {
- if(typeof obj.toString == "function" && obj.toString() != "")
- {
- return lineadder.addLine(level + 1,null,"string",obj.toString());
- }
- if(lineadder.noProps != undefined)
- {
- lineadder.noProps(level + 1);
- return nestedObjectDump.proceed;
- }
- }
- props.sort();
- objs.sort();
- var bret = true;
- var i = 0;
- while(i < props.length)
- {
- if(nestedObjectDump(level + 1,props[i],obj[props[i]],lineadder) == nestedObjectDump.stop)
- {
- bret = false;
- break;
- }
- i++;
- }
- if(bret)
- {
- var i = 0;
- while(i < objs.length)
- {
- if(!nestedObjectDump(level + 1,objs[i],obj[objs[i]],lineadder))
- {
- bret = false;
- }
- i++;
- }
- }
- return nestedObjectDump.proceed;
- }
- return lineadder.addLine(level,objname,typeof obj,obj);
- };
- nestedObjectDump.proceed = 1;
- nestedObjectDump.skip = 2;
- nestedObjectDump.stop = 3;
- nestedObjectDump.callcount = 0;
- nestedObjectDump.objcount = 0;
- Object.registerClass("NetDebugConfig",NetDebugConfig);
- NetDebugEvent.prototype.init = function()
- {
- this.EventType = "DebugEvent";
- this.Source = "Client";
- this.MovieUrl = unescape(_root._url);
- this.initDate();
- };
- NetDebugEvent.prototype.initDate = function()
- {
- var now = new Date();
- this.Date = now;
- this.Time = now.getTime();
- };
- NetDebugErrorEvent.prototype = new NetDebugEvent();
- NetDebugTraceEvent.prototype = new NetDebugEvent();
- NetDebugTraceNetServicesEvent.prototype = new NetDebugEvent();
- NetDebugNCEvent.prototype = new NetDebugEvent();
- NetDebugResultEvent.prototype = new NetDebugNCEvent();
- NetDebugStatusEvent.prototype = new NetDebugNCEvent();
- NetDebugConnectEvent.prototype = new NetDebugNCEvent();
- NetDebugCallEvent.prototype = new NetDebugNCEvent();
- NetDebugCloseEvent.prototype = new NetDebugNCEvent();
- NetDebugAddHeaderEvent.prototype = new NetDebugNCEvent();
- NetDebugRtmpLogEvent.prototype = new NetDebugNCEvent();
- NetDebugDuplicateNCDErrorEvent.prototype = new NetDebugNCEvent();
- NetDebugFailedSendErrorEvent.prototype = new NetDebugNCEvent();
- NetDebugInfoErrorEvent.prototype = new NetDebugNCEvent();
- NetDebugResultEvent.prototype = new NetDebugNCEvent();
- _global.StripNCDEventToMinmal = function(ev)
- {
- var ret = new Object();
- if(ev.EventType != null)
- {
- ret.EventType = ev.EventType;
- }
- if(ev.Source != null)
- {
- ret.Source = ev.Source;
- }
- if(ev.MovieUrl != null)
- {
- ret.MovieUrl = ev.MovieUrl;
- }
- if(ev.Date != null)
- {
- ret.Date = ev.Date;
- }
- if(ev.Time != null)
- {
- ret.Time = ev.Time;
- }
- if(ev.Protocol != null)
- {
- ret.Protocol = ev.Protocol;
- }
- if(ev.DebugId != null)
- {
- ret.DebugId = ev.DebugId;
- }
- return ret;
- };
- NetConnection.prototype.attachDebug = function()
- {
- if(!this.m_Attached)
- {
- this.m_Attached = true;
- this.m_HeaderAdded = false;
- this.m_Config = new NetDebugConfig();
- copyProperties(this.m_Config,getNetDebug().m_Config);
- this.m_Protocol = "none";
- this.m_Id = getNetDebug().addNetConnection(this);
- }
- };
- NetConnection.prototype.sendDebugEvent = function(eventobj)
- {
- eventobj.Protocol = this.m_Protocol;
- eventobj.DebugId = this.m_Id;
- return getNetDebug().onEvent(eventobj);
- };
- NetConnection.prototype.sendServerEvent = function(eventobj)
- {
- eventobj.MovieUrl = unescape(_root._url);
- if(this.sendDebugEvent(eventobj))
- {
- }
- };
- NetConnection.prototype.sendClientEvent = function(eventobj)
- {
- if(this.m_Config.m_debug && this.m_Config.client.m_debug)
- {
- if(this.m_Config.client.http && this.m_Protocol == "http" || this.m_Config.client.rtmp && this.m_Protocol == "rtmp")
- {
- if(this.sendDebugEvent(eventobj))
- {
- }
- }
- }
- };
- NetConnection.prototype.addNetDebugHeader = function()
- {
- if(!this.m_HeaderAdded)
- {
- this.m_HeaderAdded = true;
- if(this.m_Config.m_debug && this.m_Config.app_server.m_debug && this.m_Protocol == "http")
- {
- this.realaddHeader("amf_server_debug",true,this.m_Config.app_server);
- }
- else
- {
- this.realaddHeader("amf_server_debug",true,undefined);
- }
- }
- };
- NetConnection.prototype.updateConfig = function(config)
- {
- this.attachDebug();
- copyProperties(this.m_Config,config);
- this.m_HeaderAdded = false;
- };
- NetConnection.prototype.isRealTime = function()
- {
- return this.m_Protocol == "rtmp";
- };
- NetConnection.prototype.setupRecordset = function()
- {
- this.attachDebug();
- this.m_Config.client.http = this.m_Config.client.recordset;
- };
- NetConnection.prototype.setDebugId = function(id)
- {
- this.attachDebug();
- this.m_Id = id;
- };
- NetConnection.prototype.getDebugId = function()
- {
- this.attachDebug();
- return this.m_Id;
- };
- NetConnection.prototype.trace = function(traceobj)
- {
- this.attachDebug();
- if(this.m_Config.m_debug && this.m_Config.client.m_debug && this.m_Config.client.trace)
- {
- this.sendDebugEvent(new NetDebugTraceEvent(traceobj));
- }
- };
- NetConnection.prototype.getDebugConfig = function()
- {
- this.attachDebug();
- return this.m_Config;
- };
- if(!NetConnection.prototype.netDebugProxyFunctions)
- {
- NetConnection.prototype.netDebugProxyFunctions = true;
- NetConnection.prototype.realconnect = NetConnection.prototype.connect;
- NetConnection.prototype.realcall = NetConnection.prototype.call;
- NetConnection.prototype.realclose = NetConnection.prototype.close;
- NetConnection.prototype.realaddHeader = NetConnection.prototype.addHeader;
- NetConnection.prototype.connect = netDebugProxyConnect;
- NetConnection.prototype.call = netDebugproxyCall;
- NetConnection.prototype.close = netDebugproxyClose;
- NetConnection.prototype.addHeader = netDebugproxyAddHeader;
- }
- RTMPClientIDResponse.prototype.onResult = function(cid)
- {
- this.m_NC.m_ClientId = cid;
- getNetDebug().sendCommand(new AddRTMPClientCommand(this.m_ConnectString,cid));
- };
- NetDebugResponseProxy.prototype.onDebugEvents = function(debugevents)
- {
- var i = 0;
- while(i < debugevents.length)
- {
- this.m_SourceNC.sendServerEvent(debugevents[i]);
- i++;
- }
- };
- NetDebugResponseProxy.prototype.onResult = function(resultobj)
- {
- this.m_SourceNC.sendClientEvent(new NetDebugResultEvent(resultobj));
- this.m_OriginalNR.onResult(resultobj);
- };
- NetDebugResponseProxy.prototype.onStatus = function(statusobj)
- {
- this.m_SourceNC.sendClientEvent(new NetDebugStatusEvent(statusobj));
- if(this.m_OriginalNR.onStatus != undefined)
- {
- this.m_OriginalNR.onStatus(statusobj);
- }
- else
- {
- _global.System.onStatus(statusobj);
- }
- };
- NetDebugResponseProxy.prototype.__resolve = function(name)
- {
- this.m_SourceNC.sendClientEvent(new NetDebugReceiveCallEvent(name,arguments));
- this.m_OriginalNR[name].apply(arguments);
- };
- GlobalLocalConnection.prototype.setDomainName = function(domainname)
- {
- if(domainname != null && domainname != "")
- {
- this.sendPrefix = domainname + ":";
- }
- else
- {
- this.sendPrefix = "";
- }
- };
- GlobalLocalConnection.prototype.send = function(dataobj)
- {
- return this.sendRaw("onData",dataobj);
- };
- GlobalLocalConnection.prototype.sendCommand = function(commandobj)
- {
- return this.sendRaw("onCommand",commandobj);
- };
- GlobalLocalConnection.prototype.sendRaw = function(functionname, obj)
- {
- var suc = true;
- var i = 0;
- while(i < this.sendnames.length)
- {
- suc &= _global.g_NetDebugLocalConnection.send(this.sendPrefix + this.sendnames[i],functionname,obj);
- i++;
- }
- return suc;
- };
- LocalCommand.prototype.init = function(commandname, dataobj)
- {
- this.command = commandname;
- this.data = dataobj;
- };
- UpdateNetDebugConfigCommand.prototype = new LocalCommand();
- GetConfigCommand.prototype = new LocalCommand();
- StartRTMPTraceCommand.prototype = new LocalCommand();
- AddRTMPClientCommand.prototype = new LocalCommand();
- StopRTMPTraceCommand.prototype = new LocalCommand();
- NetDebug.prototype.addNetConnection = function(nc)
- {
- this.m_ncs.push(nc);
- return this.m_NextNewId++;
- };
- NetDebug.prototype.removeNetConnection = function(nc)
- {
- var i = 0;
- while(i < this.m_ncs.length)
- {
- if(nc == this.m_ncs[i])
- {
- this.m_ncs.splice(i,1);
- break;
- }
- i++;
- }
- };
- NetDebug.prototype.sendDebugEvent = function(eventobj)
- {
- if(!this.m_glc.send(eventobj))
- {
- this.m_glc.send(new NetDebugFailedSendErrorEvent(StripNCDEventToMinmal(eventobj)));
- return false;
- }
- return true;
- };
- NetDebug.prototype.sendCommand = function(commandobj)
- {
- return this.m_glc.sendCommand(commandobj);
- };
- NetDebug.prototype.requestNewConfig = function()
- {
- return this.sendCommand(new GetConfigCommand());
- };
- NetDebug.prototype.updateConfig = function(config)
- {
- copyProperties(this.m_Config,config);
- var i = 0;
- while(i < this.m_ncs.length)
- {
- if(this.m_ncs[i] != null)
- {
- this.m_ncs[i].updateConfig(config);
- }
- i++;
- }
- };
- NetDebug.prototype.sendStatus = function(statusobj)
- {
- if(this.m_Config.m_debug && this.m_Config.client.m_debug)
- {
- return this.m_glc.send(new NetDebugStatusEvent(statusobj));
- }
- };
- NetDebug.prototype.onEvent = function(eventobj)
- {
- return this.sendDebugEvent(eventobj);
- };
- NetDebug.prototype.onEventError = function(errorobj)
- {
- return this.sendDebugEvent(new NetDebugErrorEvent(errorobj));
- };
- NetDebug.prototype.onReceiveCommand = function(commandobj)
- {
- this[commandobj.command](commandobj.data);
- };
- NetDebug.prototype.onReceiveError = function(errorobj)
- {
- this.sendDebugEvent(new NetDebugErrorEvent(errorobj));
- };
- NetDebug.prototype.traceNetServices = function(who, severity, number, message)
- {
- if(this.m_Config.m_debug && this.m_Config.client.m_debug && this.m_Config.client.trace)
- {
- if(this.sendDebugEvent(new NetDebugTraceNetServicesEvent(who,severity,number,message)))
- {
- }
- }
- };
- NetDebug.prototype.trace = function(traceobj)
- {
- if(this.m_Config.m_debug && this.m_Config.client.m_debug && this.m_Config.client.trace)
- {
- if(this.sendDebugEvent(new NetDebugTraceEvent(traceobj)))
- {
- }
- }
- };
- if(_global.netDebugInstance == undefined)
- {
- _global.netDebugInstance = new NetDebug();
- }
- NetDebug.trace = function(obj)
- {
- getNetDebug().trace(obj);
- };
- NetDebug.traceNetServices = function(who, severity, number, message)
- {
- getNetDebug().traceNetServices(who,severity,number,message);
- };
- NetDebug.getVersion = function()
- {
- return getNetDebugVersion();
- };
- NetDebug.globalOnStatus = function(statusobj)
- {
- getNetDebug().sendStatus(statusobj);
- };
- if(_global.System.onStatus == undefined)
- {
- _global.System.onStatus = NetDebug.globalOnStatus;
- }
- _global.RsDataProviderClass = function()
- {
- this.init();
- };
- RsDataProviderClass.prototype.init = function()
- {
- this.items = new Array();
- this.uniqueID = 0;
- this.views = new Array();
- };
- RsDataProviderClass.prototype.addView = function(viewRef)
- {
- this.views.push(viewRef);
- var eventObj = {event:"updateAll"};
- viewRef.modelChanged(eventObj);
- };
- RsDataProviderClass.prototype.addItemAt = function(index, value)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- if(index < 0)
- {
- return undefined;
- }
- if(index < this.getLength())
- {
- this.items.splice(index,0,"tmp");
- }
- this.items[index] = new Object();
- if(typeof value == "object")
- {
- this.items[index] = value;
- }
- this.items[index].__ID__ = this.uniqueID++;
- var eventObj = {event:"addRows",firstRow:index,lastRow:index};
- this.updateViews(eventObj);
- };
- RsDataProviderClass.prototype.addItem = function(value)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- this.addItemAt(this.getLength(),value);
- };
- RsDataProviderClass.prototype.removeItemAt = function(index)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- if(index < 0 || index >= this.getLength())
- {
- return undefined;
- }
- var tmpItm = this.items[index];
- this.items.splice(index,1);
- var eventObj = {event:"deleteRows",firstRow:index,lastRow:index};
- this.updateViews(eventObj);
- return tmpItm;
- };
- RsDataProviderClass.prototype.removeAll = function()
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- this.items = new Array();
- this.updateViews({event:"deleteRows",firstRow:0,lastRow:this.getLength() - 1});
- };
- RsDataProviderClass.prototype.replaceItemAt = function(index, itemObj)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- if(index < 0 || index >= this.getLength())
- {
- return undefined;
- }
- var tmpID = this.getItemID(index);
- this.items[index] = itemObj;
- this.items[index].__ID__ = tmpID;
- this.updateViews({event:"updateRows",firstRow:index,lastRow:index});
- };
- RsDataProviderClass.prototype.getLength = function()
- {
- return this.items.length;
- };
- RsDataProviderClass.prototype.getItemAt = function(index)
- {
- return this.items[index];
- };
- RsDataProviderClass.prototype.getItemID = function(index)
- {
- return this.items[index].__ID__;
- };
- RsDataProviderClass.prototype.sortItemsBy = function(fieldName, order)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- this.items.sortOn(fieldName);
- if(order == "DESC")
- {
- this.items.reverse();
- }
- this.updateViews({event:"sort"});
- };
- RsDataProviderClass.prototype.updateViews = function(eventObj)
- {
- var i = 0;
- while(i < this.views.length)
- {
- this.views[i].modelChanged(eventObj);
- i++;
- }
- };
- _global.RecordSet = function(columnNames)
- {
- if(this.mTitles != null)
- {
- this.views = new Array();
- return undefined;
- }
- this.init();
- if(this.serverInfo == null)
- {
- this.mTitles = columnNames;
- return undefined;
- }
- if(this.serverInfo.version != 1)
- {
- NetServices.trace("RecordSet","warning",100,"Received incompatible recordset version from server");
- return undefined;
- }
- this.mTitles = this.serverInfo.columnNames;
- this.mRecordsAvailable = 0;
- this.setData(this.serverInfo.cursor != null ? this.serverInfo.cursor - 1 : 0,this.serverInfo.initialData);
- if(this.serverInfo.initialData.length != this.serverInfo.totalCount)
- {
- this.mRecordSetId = this.serverInfo.id;
- if(this.mRecordSetId != null)
- {
- this.serviceName = this.serverInfo.serviceName != null ? this.serverInfo.serviceName : "RecordSet";
- this.mTotalCount = this.serverInfo.totalCount;
- this.mDeliveryMode = "ondemand";
- this.mAllNotified = false;
- this.mOutstandingRecordCount = 0;
- }
- else
- {
- NetServices.trace("RecordSet","warning",102,"Missing some records, but there\'s no recordset id");
- }
- }
- this.serverInfo = null;
- };
- RecordSet.prototype = new RsDataProviderClass();
- Object.registerClass("RecordSet",RecordSet);
- RecordSet.prototype._setParentService = function(service)
- {
- this.gateway_conn = service.nc;
- };
- RecordSet.prototype.getRecordSetService = function()
- {
- if(this.mRecordSetService == null)
- {
- if(this.gateway_conn == null)
- {
- this.gateway_conn = NetServices.createGatewayConnection();
- }
- else if(_global.netDebugInstance != undefined)
- {
- this.gateway_conn = this.gateway_conn.clone();
- }
- if(_global.netDebugInstance != undefined)
- {
- this.gateway_conn.setupRecordset();
- this.gateway_conn.setDebugId("RecordSet " + this.mRecordSetId);
- }
- this.mRecordSetService = this.gateway_conn.getService(this.serviceName,this);
- if(this.mRecordSetService == null)
- {
- NetServices.trace("RecordSet","warning",101,"Failed to create recordset service");
- this.mRecordSetService = 0;
- }
- }
- return this.mRecordSetService;
- };
- RecordSet.prototype.getColumnNames = function()
- {
- return this.mTitles;
- };
- RecordSet.prototype.getLength = function()
- {
- if(this.mRecordSetID != null)
- {
- return this.mTotalCount;
- }
- return this.items.length;
- };
- RecordSet.prototype.getItemAt = function(index)
- {
- if(this.mRecordSetId == null)
- {
- return this.items[index];
- }
- if(index < 0 || index >= this.getLength())
- {
- NetServices.trace("RecordSet","warning",104,"getItemAt(" + index + ") index out of range");
- return null;
- }
- this.requestRecord(index);
- var result = this.items[index];
- if(result == 1)
- {
- return "in progress";
- }
- return result;
- };
- RecordSet.prototype.setField = function(index, fieldName, value)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- if(index < 0 || index >= this.getLength())
- {
- return undefined;
- }
- this.items[index][fieldName] = value;
- this.updateViews({event:"updateRows",firstRow:index,lastRow:index});
- };
- RecordSet.prototype.filter = function(filterFunction, context)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- var result = new RecordSet(this.mTitles);
- var i = 0;
- while(i < this.getLength())
- {
- var item = this.getItemAt(i);
- if(item != null && item != 1 && filterFunction(item,context))
- {
- result.addItem(item);
- }
- i++;
- }
- return result;
- };
- RecordSet.prototype.sort = function(compareFunc)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- this.items.sort(compareFunc);
- this.updateViews({event:"sort"});
- };
- RecordSet.prototype.isLocal = function()
- {
- return this.mRecordSetID == null;
- };
- RecordSet.prototype.isFullyPopulated = function()
- {
- return this.isLocal();
- };
- RecordSet.prototype.getNumberAvailable = function()
- {
- if(this.isLocal())
- {
- return this.getLength();
- }
- return this.mRecordsAvailable;
- };
- RecordSet.prototype.setDeliveryMode = function(mode, pagesize, numPrefetchPages)
- {
- this.mDeliveryMode = mode;
- this.stopFetchAll();
- if(mode == "ondemand")
- {
- return undefined;
- }
- if(pagesize == null)
- {
- pagesize = this.views[0].getRowCount();
- if(pagesize == null)
- {
- pagesize = 25;
- }
- }
- if(mode == "page")
- {
- if(numPrefetchPages == null)
- {
- numPrefetchPages = 0;
- }
- this.mPageSize = pagesize;
- this.mNumPrefetchPages = numPrefetchPages;
- }
- else if(mode == "fetchall")
- {
- this.stopFetchAll();
- this.startFetchAll(pagesize);
- }
- else
- {
- NetServices.trace("RecordSet","warning",107,"SetDeliveryMode: unknown mode string");
- }
- };
- RecordSet.prototype.getRecords_Result = function(info)
- {
- this.setData(info.Cursor - 1,info.Page);
- this.mOutstandingRecordCount -= info.Page.length;
- this.updateViews({event:"updateRows",firstRow:info.Cursor - 1,lastRow:info.Cursor - 1 + info.Page.length - 1});
- if(this.mRecordsAvailable == this.mTotalCount && !this.mAllNotified)
- {
- this.updateViews({event:"allRows"});
- this.mRecordSetService.release();
- this.mAllNotified = true;
- this.mRecordSetID = null;
- this.mRecordSetService = null;
- }
- };
- RecordSet.prototype.release_Result = function()
- {
- };
- RecordSet.prototype.arrayToObject = function(anArray)
- {
- if(this.mTitles == null)
- {
- NetServices.trace("RecordSet","warning",105,"getItem: titles are not available");
- return null;
- }
- var result = new Object();
- var i = 0;
- while(i < anArray.length)
- {
- var title = this.mTitles[i];
- if(title == null)
- {
- title = "column" + i + 1;
- }
- result[title] = anArray[i];
- i++;
- }
- return result;
- };
- RecordSet.prototype.setData = function(start, dataArray)
- {
- var i = 0;
- while(i < dataArray.length)
- {
- var index = i + start;
- var rec = this.items[index];
- if(rec != null && rec != 1)
- {
- NetServices.trace("RecordSet","warning",106,"Already got record # " + recordIndex);
- }
- else
- {
- this.mRecordsAvailable += 1;
- }
- this.items[index] = this.arrayToObject(dataArray[i]);
- this.items[index].__ID__ = this.uniqueID++;
- i++;
- }
- };
- RecordSet.prototype.requestOneRecord = function(index)
- {
- if(this.items[index] == null)
- {
- this.getRecordSetService().getRecords(this.mRecordSetId,index + 1,1);
- this.mOutstandingRecordCount = this.mOutstandingRecordCount + 1;
- this.items[index] = 1;
- this.updateViews({event:"fetchRows",firstRow:index,lastRow:index});
- }
- };
- RecordSet.prototype.requestRecord = function(index)
- {
- if(this.mDeliveryMode != "page")
- {
- this.requestOneRecord(index);
- return undefined;
- }
- var firstIndex = int(index / this.mPageSize) * this.mPageSize;
- var lastIndex = firstIndex + this.mPageSize * (this.mNumPrefetchPages + 1) - 1;
- this.requestRecordRange(firstIndex,lastIndex);
- };
- RecordSet.prototype.requestRecordRange = function(index, lastIndex)
- {
- var highestRequested = -1;
- if(index < 0)
- {
- index = 0;
- }
- if(lastIndex >= this.getLength())
- {
- lastIndex = this.getLength() - 1;
- }
- while(index <= lastIndex)
- {
- while(index <= lastIndex && this.items[index] != null)
- {
- index++;
- }
- var first = index;
- while(index <= lastIndex && this.items[index] == null)
- {
- this.mOutstandingRecordCount = this.mOutstandingRecordCount + 1;
- this.items[index] = 1;
- index++;
- }
- var last = index - 1;
- if(first <= last)
- {
- this.getRecordSetService().getRecords(this.mRecordSetId,first + 1,last - first + 1);
- highestRequested = last;
- this.updateViews({event:"fetchRows",firstRow:first,lastRow:last});
- }
- }
- return highestRequested;
- };
- RecordSet.prototype.startFetchAll = function(pagesize)
- {
- this.mDataFetcher.disable();
- this.mDataFetcher = new RsDataFetcher(this,pagesize);
- };
- RecordSet.prototype.stopFetchAll = function()
- {
- this.mDataFetcher.disable();
- this.mDataFetcher = null;
- };
- RecordSet.prototype.checkLocal = function()
- {
- if(this.isLocal())
- {
- return true;
- }
- NetServices.trace("RecordSet","warning",108,"Operation not allowed on partial recordset");
- return false;
- };
- _global.RsDataFetcher = function(recordSet, increment)
- {
- this.mRecordSet = recordSet;
- this.mRecordSet.addView(this);
- this.mIncrement = increment;
- this.mNextRecord = 0;
- this.mEnabled = true;
- this.doNext();
- };
- RsDataFetcher.prototype.disable = function()
- {
- this.mEnabled = false;
- this.mRecordSet.removeView(this);
- };
- RsDataFetcher.prototype.doNext = function()
- {
- if(!this.mEnabled)
- {
- return undefined;
- }
- while(true)
- {
- if(this.mNextRecord >= this.mRecordSet.getLength())
- {
- return undefined;
- }
- this.mHighestRequested = this.mRecordSet.requestRecordRange(this.mNextRecord,this.mNextRecord + this.mIncrement - 1);
- this.mNextRecord += this.mIncrement;
- if(this.mHighestRequested > 0)
- {
- return undefined;
- }
- }
- };
- RsDataFetcher.prototype.modelChanged = function(eventObj)
- {
- if(eventObj.event == "updateRows" && eventObj.firstRow <= this.mHighestRequested && eventObj.lastRow >= this.mHighestRequested)
- {
- this.doNext();
- }
- if(eventObj.event == "allRows")
- {
- this.disable();
- }
- };
- _global.NetServiceProxyResponder = function(service, methodName)
- {
- this.service = service;
- this.methodName = methodName;
- };
- NetServiceProxyResponder.prototype.onResult = function(result)
- {
- var client = this.service.client;
- result._setParentService(this.service);
- var func = this.methodName + "_Result";
- if(typeof client[func] == "function")
- {
- client[func](result);
- }
- else if(typeof client.onResult == "function")
- {
- client.onResult(result);
- }
- else
- {
- NetServices.trace("NetServices","info",1,func + " was received from server: " + result);
- }
- };
- NetServiceProxyResponder.prototype.onStatus = function(result)
- {
- var client = this.service.client;
- var func = this.methodName + "_Status";
- if(typeof client[func] == "function")
- {
- client[func](result);
- }
- else if(typeof client.onStatus == "function")
- {
- client.onStatus(result);
- }
- else if(typeof _root.onStatus == "function")
- {
- _root.onStatus(result);
- }
- else if(typeof _global.System.onStatus == "function")
- {
- _global.System.onStatus(result);
- }
- else
- {
- NetServices.trace("NetServices","info",2,func + " was received from server: " + result["class"] + " " + result.description);
- }
- };
- Object.registerClass("NetServiceProxy",NetServiceProxy);
- _global.NetServiceProxy = function(nc, serviceName, client)
- {
- if(nc != null)
- {
- this.nc = nc;
- this.serviceName = serviceName;
- this.client = client;
- }
- };
- NetServiceProxy.prototype._setParentService = function(service)
- {
- this.nc = service.nc;
- this.client = service.client;
- };
- NetServiceProxy.prototype.__resolve = function(methodName)
- {
- var f = function()
- {
- if(this.client != null)
- {
- arguments.unshift(new NetServiceProxyResponder(this,methodName));
- }
- else if(typeof arguments[0].onResult != "function")
- {
- NetServices.trace("NetServices","warning",3,"There is no defaultResponder, but no responder was given in call to " + methodName);
- arguments.unshift(new NetServiceProxyResponder(this,methodName));
- }
- arguments.unshift(this.serviceName + "." + methodName);
- return this.nc.call.apply(this.nc,arguments);
- };
- return f;
- };
- NetConnection.prototype.getService = function(serviceName, client)
- {
- var result = new NetServiceProxy(this,serviceName,client);
- return result;
- };
- NetConnection.prototype.setCredentials = function(userid, password)
- {
- this.addHeader("Credentials",false,{userid:userid,password:password});
- };
- NetConnection.prototype.RequestPersistentHeader = function(info)
- {
- this.addHeader(info.name,info.mustUnderstand,info.data);
- };
- NetConnection.prototype.ReplaceGatewayUrl = function(newUrl)
- {
- this.connect(newUrl);
- };
- NetConnection.prototype.clone = function()
- {
- var nc = new NetConnection();
- nc.connect(this.uri);
- return nc;
- };
- if(_global.NetServices == null)
- {
- _global.NetServices = new Object();
- NetServices.gatewayUrl = gatewayUrl;
- }
- NetServices.setDefaultGatewayUrl = function(url)
- {
- NetServices.defaultGatewayUrl = url;
- };
- NetServices.setGatewayUrl = function(url)
- {
- NetServices.gatewayUrl = url;
- };
- NetServices.createGatewayConnection = function(url)
- {
- if(url == undefined)
- {
- if(NetServices.isHttpUrl(_root._url))
- {
- url = NetServices.gatewayUrl;
- if(url == undefined)
- {
- url = NetServices.defaultGatewayUrl;
- if(url != undefined)
- {
- if(NetServices.isHttpUrl(url))
- {
- var firstSlashPos = url.indexOf("/",8);
- if(firstSlashPos >= 0)
- {
- url = url.substring(firstSlashPos);
- }
- }
- var hostUrl = NetServices.getHostUrl();
- if(hostUrl != null)
- {
- url = hostUrl + url;
- }
- }
- }
- }
- else
- {
- url = NetServices.defaultGatewayUrl;
- }
- }
- if(url == undefined)
- {
- NetServices.trace("NetServices","warning",4,"createGatewayConnection - gateway url is undefined");
- return null;
- }
- var nc = new NetConnection();
- nc.connect(url);
- return nc;
- };
- NetServices.getHostUrl = function()
- {
- if(!NetServices.isHttpUrl(_root._url))
- {
- return null;
- }
- var firstSlashPos = _root._url.indexOf("/",8);
- if(firstSlashPos < 0)
- {
- return null;
- }
- return _root._url.substring(0,firstSlashPos);
- };
- NetServices.isHttpUrl = function(url)
- {
- return url.indexOf("http://") == 0 || url.indexOf("https://") == 0;
- };
- NetServices.trace = function(who, severity, number, message)
- {
- var fullMessage = who + " " + severity + " " + number + ": " + message;
- trace(fullMessage);
- NetDebug.traceNetServices(who,severity,number,message);
- };
- NetServices.getVersion = function()
- {
- return 1;
- };
- _global.DataGlue = function(dataProvider)
- {
- this.dataProvider = dataProvider;
- };
- _global.DataGlue.bindFormatStrings = function(dataConsumer, dataProvider, labelString, dataString)
- {
- var proxy = new DataGlue(dataProvider);
- proxy.labelString = labelString;
- proxy.dataString = dataString;
- proxy.getItemAt = _global.DataGlue.getItemAt_FormatString;
- dataConsumer.setDataProvider(proxy);
- };
- _global.DataGlue.bindFormatFunction = function(dataConsumer, dataProvider, formatFunction)
- {
- var proxy = new DataGlue(dataProvider);
- proxy.formatFunction = formatFunction;
- proxy.getItemAt = _global.DataGlue.getItemAt_FormatFunction;
- dataConsumer.setDataProvider(proxy);
- };
- _global.DataGlue.prototype.addView = function(viewRef)
- {
- return this.dataProvider.addView(viewRef);
- };
- _global.DataGlue.prototype.getLength = function()
- {
- return this.dataProvider.getLength();
- };
- _global.DataGlue.prototype.format = function(formatString, record)
- {
- var tokens = formatString.split("#");
- var result = "";
- var i = 0;
- while(i < tokens.length)
- {
- result += tokens[i];
- result += tokens[i + 1] != "" ? record[tokens[i + 1]] : "#";
- i += 2;
- }
- return result;
- };
- _global.DataGlue.getItemAt_FormatString = function(index)
- {
- var record = this.dataProvider.getItemAt(index);
- if(record == "in progress" || record == undefined)
- {
- return record;
- }
- return {label:this.format(this.labelString,record),data:(this.dataString != null ? this.format(this.dataString,record) : record)};
- };
- _global.DataGlue.getItemAt_FormatFunction = function(index)
- {
- var record = this.dataProvider.getItemAt(index);
- if(record == "in progress" || record == undefined)
- {
- return record;
- }
- return this.formatFunction(record);
- };
- _global.DataGlue.prototype.getItemID = function(index)
- {
- return this.dataProvider.getItemID(index);
- };
- _global.DataGlue.prototype.addItemAt = function(index, value)
- {
- return this.dataProvider.addItemAt(index,value);
- };
- _global.DataGlue.prototype.addItem = function(value)
- {
- return this.dataProvider.addItem(value);
- };
- _global.DataGlue.prototype.removeItemAt = function(index)
- {
- return this.dataProvider.removeItemAt(index);
- };
- _global.DataGlue.prototype.removeAll = function()
- {
- return this.dataProvider.removeAll();
- };
- _global.DataGlue.prototype.replaceItemAt = function(index, itemObj)
- {
- return this.dataProvider.replaceItemAt(index,itemObj);
- };
- _global.DataGlue.prototype.sortItemsBy = function(fieldName, order)
- {
- return this.dataProvider.sortItemsBy(fieldName,order);
- };
- _global.RsDataProviderClass = function()
- {
- this.init();
- };
- RsDataProviderClass.prototype.init = function()
- {
- this.items = new Array();
- this.uniqueID = 0;
- this.views = new Array();
- };
- RsDataProviderClass.prototype.addView = function(viewRef)
- {
- this.views.push(viewRef);
- var eventObj = {event:"updateAll"};
- viewRef.modelChanged(eventObj);
- };
- RsDataProviderClass.prototype.addItemAt = function(index, value)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- if(index < 0)
- {
- return undefined;
- }
- if(index < this.getLength())
- {
- this.items.splice(index,0,"tmp");
- }
- this.items[index] = new Object();
- if(typeof value == "object")
- {
- this.items[index] = value;
- }
- this.items[index].__ID__ = this.uniqueID++;
- var eventObj = {event:"addRows",firstRow:index,lastRow:index};
- this.updateViews(eventObj);
- };
- RsDataProviderClass.prototype.addItem = function(value)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- this.addItemAt(this.getLength(),value);
- };
- RsDataProviderClass.prototype.removeItemAt = function(index)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- if(index < 0 || index >= this.getLength())
- {
- return undefined;
- }
- var tmpItm = this.items[index];
- this.items.splice(index,1);
- var eventObj = {event:"deleteRows",firstRow:index,lastRow:index};
- this.updateViews(eventObj);
- return tmpItm;
- };
- RsDataProviderClass.prototype.removeAll = function()
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- this.items = new Array();
- this.updateViews({event:"deleteRows",firstRow:0,lastRow:this.getLength() - 1});
- };
- RsDataProviderClass.prototype.replaceItemAt = function(index, itemObj)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- if(index < 0 || index >= this.getLength())
- {
- return undefined;
- }
- var tmpID = this.getItemID(index);
- this.items[index] = itemObj;
- this.items[index].__ID__ = tmpID;
- this.updateViews({event:"updateRows",firstRow:index,lastRow:index});
- };
- RsDataProviderClass.prototype.getLength = function()
- {
- return this.items.length;
- };
- RsDataProviderClass.prototype.getItemAt = function(index)
- {
- return this.items[index];
- };
- RsDataProviderClass.prototype.getItemID = function(index)
- {
- return this.items[index].__ID__;
- };
- RsDataProviderClass.prototype.sortItemsBy = function(fieldName, order)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- this.items.sortOn(fieldName);
- if(order == "DESC")
- {
- this.items.reverse();
- }
- this.updateViews({event:"sort"});
- };
- RsDataProviderClass.prototype.updateViews = function(eventObj)
- {
- var i = 0;
- while(i < this.views.length)
- {
- this.views[i].modelChanged(eventObj);
- i++;
- }
- };
- _global.RecordSet = function(columnNames)
- {
- if(this.mTitles != null)
- {
- this.views = new Array();
- return undefined;
- }
- this.init();
- if(this.serverInfo == null)
- {
- this.mTitles = columnNames;
- return undefined;
- }
- if(this.serverInfo.version != 1)
- {
- NetServices.trace("RecordSet","warning",100,"Received incompatible recordset version from server");
- return undefined;
- }
- this.mTitles = this.serverInfo.columnNames;
- this.mRecordsAvailable = 0;
- this.setData(this.serverInfo.cursor != null ? this.serverInfo.cursor - 1 : 0,this.serverInfo.initialData);
- if(this.serverInfo.initialData.length != this.serverInfo.totalCount)
- {
- this.mRecordSetId = this.serverInfo.id;
- if(this.mRecordSetId != null)
- {
- this.serviceName = this.serverInfo.serviceName != null ? this.serverInfo.serviceName : "RecordSet";
- this.mTotalCount = this.serverInfo.totalCount;
- this.mDeliveryMode = "ondemand";
- this.mAllNotified = false;
- this.mOutstandingRecordCount = 0;
- }
- else
- {
- NetServices.trace("RecordSet","warning",102,"Missing some records, but there\'s no recordset id");
- }
- }
- this.serverInfo = null;
- };
- RecordSet.prototype = new RsDataProviderClass();
- Object.registerClass("RecordSet",RecordSet);
- RecordSet.prototype._setParentService = function(service)
- {
- this.gateway_conn = service.nc;
- };
- RecordSet.prototype.getRecordSetService = function()
- {
- if(this.mRecordSetService == null)
- {
- if(this.gateway_conn == null)
- {
- this.gateway_conn = NetServices.createGatewayConnection();
- }
- else if(_global.netDebugInstance != undefined)
- {
- this.gateway_conn = this.gateway_conn.clone();
- }
- if(_global.netDebugInstance != undefined)
- {
- this.gateway_conn.setupRecordset();
- this.gateway_conn.setDebugId("RecordSet " + this.mRecordSetId);
- }
- this.mRecordSetService = this.gateway_conn.getService(this.serviceName,this);
- if(this.mRecordSetService == null)
- {
- NetServices.trace("RecordSet","warning",101,"Failed to create recordset service");
- this.mRecordSetService = 0;
- }
- }
- return this.mRecordSetService;
- };
- RecordSet.prototype.getColumnNames = function()
- {
- return this.mTitles;
- };
- RecordSet.prototype.getLength = function()
- {
- if(this.mRecordSetID != null)
- {
- return this.mTotalCount;
- }
- return this.items.length;
- };
- RecordSet.prototype.getItemAt = function(index)
- {
- if(this.mRecordSetId == null)
- {
- return this.items[index];
- }
- if(index < 0 || index >= this.getLength())
- {
- NetServices.trace("RecordSet","warning",104,"getItemAt(" + index + ") index out of range");
- return null;
- }
- this.requestRecord(index);
- var result = this.items[index];
- if(result == 1)
- {
- return "in progress";
- }
- return result;
- };
- RecordSet.prototype.setField = function(index, fieldName, value)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- if(index < 0 || index >= this.getLength())
- {
- return undefined;
- }
- this.items[index][fieldName] = value;
- this.updateViews({event:"updateRows",firstRow:index,lastRow:index});
- };
- RecordSet.prototype.filter = function(filterFunction, context)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- var result = new RecordSet(this.mTitles);
- var i = 0;
- while(i < this.getLength())
- {
- var item = this.getItemAt(i);
- if(item != null && item != 1 && filterFunction(item,context))
- {
- result.addItem(item);
- }
- i++;
- }
- return result;
- };
- RecordSet.prototype.sort = function(compareFunc)
- {
- if(!this.checkLocal())
- {
- return undefined;
- }
- this.items.sort(compareFunc);
- this.updateViews({event:"sort"});
- };
- RecordSet.prototype.isLocal = function()
- {
- return this.mRecordSetID == null;
- };
- RecordSet.prototype.isFullyPopulated = function()
- {
- return this.isLocal();
- };
- RecordSet.prototype.getNumberAvailable = function()
- {
- if(this.isLocal())
- {
- return this.getLength();
- }
- return this.mRecordsAvailable;
- };
- RecordSet.prototype.setDeliveryMode = function(mode, pagesize, numPrefetchPages)
- {
- this.mDeliveryMode = mode;
- this.stopFetchAll();
- if(mode == "ondemand")
- {
- return undefined;
- }
- if(pagesize == null)
- {
- pagesize = this.views[0].getRowCount();
- if(pagesize == null)
- {
- pagesize = 25;
- }
- }
- if(mode == "page")
- {
- if(numPrefetchPages == null)
- {
- numPrefetchPages = 0;
- }
- this.mPageSize = pagesize;
- this.mNumPrefetchPages = numPrefetchPages;
- }
- else if(mode == "fetchall")
- {
- this.stopFetchAll();
- this.startFetchAll(pagesize);
- }
- else
- {
- NetServices.trace("RecordSet","warning",107,"SetDeliveryMode: unknown mode string");
- }
- };
- RecordSet.prototype.getRecords_Result = function(info)
- {
- this.setData(info.Cursor - 1,info.Page);
- this.mOutstandingRecordCount -= info.Page.length;
- this.updateViews({event:"updateRows",firstRow:info.Cursor - 1,lastRow:info.Cursor - 1 + info.Page.length - 1});
- if(this.mRecordsAvailable == this.mTotalCount && !this.mAllNotified)
- {
- this.updateViews({event:"allRows"});
- this.mRecordSetService.release();
- this.mAllNotified = true;
- this.mRecordSetID = null;
- this.mRecordSetService = null;
- }
- };
- RecordSet.prototype.release_Result = function()
- {
- };
- RecordSet.prototype.arrayToObject = function(anArray)
- {
- if(this.mTitles == null)
- {
- NetServices.trace("RecordSet","warning",105,"getItem: titles are not available");
- return null;
- }
- var result = new Object();
- var i = 0;
- while(i < anArray.length)
- {
- var title = this.mTitles[i];
- if(title == null)
- {
- title = "column" + i + 1;
- }
- result[title] = anArray[i];
- i++;
- }
- return result;
- };
- RecordSet.prototype.setData = function(start, dataArray)
- {
- var i = 0;
- while(i < dataArray.length)
- {
- var index = i + start;
- var rec = this.items[index];
- if(rec != null && rec != 1)
- {
- NetServices.trace("RecordSet","warning",106,"Already got record # " + recordIndex);
- }
- else
- {
- this.mRecordsAvailable += 1;
- }
- this.items[index] = this.arrayToObject(dataArray[i]);
- this.items[index].__ID__ = this.uniqueID++;
- i++;
- }
- };
- RecordSet.prototype.requestOneRecord = function(index)
- {
- if(this.items[index] == null)
- {
- this.getRecordSetService().getRecords(this.mRecordSetId,index + 1,1);
- this.mOutstandingRecordCount = this.mOutstandingRecordCount + 1;
- this.items[index] = 1;
- this.updateViews({event:"fetchRows",firstRow:index,lastRow:index});
- }
- };
- RecordSet.prototype.requestRecord = function(index)
- {
- if(this.mDeliveryMode != "page")
- {
- this.requestOneRecord(index);
- return undefined;
- }
- var firstIndex = int(index / this.mPageSize) * this.mPageSize;
- var lastIndex = firstIndex + this.mPageSize * (this.mNumPrefetchPages + 1) - 1;
- this.requestRecordRange(firstIndex,lastIndex);
- };
- RecordSet.prototype.requestRecordRange = function(index, lastIndex)
- {
- var highestRequested = -1;
- if(index < 0)
- {
- index = 0;
- }
- if(lastIndex >= this.getLength())
- {
- lastIndex = this.getLength() - 1;
- }
- while(index <= lastIndex)
- {
- while(index <= lastIndex && this.items[index] != null)
- {
- index++;
- }
- var first = index;
- while(index <= lastIndex && this.items[index] == null)
- {
- this.mOutstandingRecordCount = this.mOutstandingRecordCount + 1;
- this.items[index] = 1;
- index++;
- }
- var last = index - 1;
- if(first <= last)
- {
- this.getRecordSetService().getRecords(this.mRecordSetId,first + 1,last - first + 1);
- highestRequested = last;
- this.updateViews({event:"fetchRows",firstRow:first,lastRow:last});
- }
- }
- return highestRequested;
- };
- RecordSet.prototype.startFetchAll = function(pagesize)
- {
- this.mDataFetcher.disable();
- this.mDataFetcher = new RsDataFetcher(this,pagesize);
- };
- RecordSet.prototype.stopFetchAll = function()
- {
- this.mDataFetcher.disable();
- this.mDataFetcher = null;
- };
- RecordSet.prototype.checkLocal = function()
- {
- if(this.isLocal())
- {
- return true;
- }
- NetServices.trace("RecordSet","warning",108,"Operation not allowed on partial recordset");
- return false;
- };
- _global.RsDataFetcher = function(recordSet, increment)
- {
- this.mRecordSet = recordSet;
- this.mRecordSet.addView(this);
- this.mIncrement = increment;
- this.mNextRecord = 0;
- this.mEnabled = true;
- this.doNext();
- };
- RsDataFetcher.prototype.disable = function()
- {
- this.mEnabled = false;
- this.mRecordSet.removeView(this);
- };
- RsDataFetcher.prototype.doNext = function()
- {
- if(!this.mEnabled)
- {
- return undefined;
- }
- while(true)
- {
- if(this.mNextRecord >= this.mRecordSet.getLength())
- {
- return undefined;
- }
- this.mHighestRequested = this.mRecordSet.requestRecordRange(this.mNextRecord,this.mNextRecord + this.mIncrement - 1);
- this.mNextRecord += this.mIncrement;
- if(this.mHighestRequested > 0)
- {
- return undefined;
- }
- }
- };
- RsDataFetcher.prototype.modelChanged = function(eventObj)
- {
- if(eventObj.event == "updateRows" && eventObj.firstRow <= this.mHighestRequested && eventObj.lastRow >= this.mHighestRequested)
- {
- this.doNext();
- }
- if(eventObj.event == "allRows")
- {
- this.disable();
- }
- };
- trace("Try to Connect:");
- if(isGatewayOpen == null)
- {
- isGatewayOpen = true;
- NetServices.setDefaultGatewayUrl("http://tracking.exposurelab.com/flashservices/gateway");
- gatewayConnnection = NetServices.createGatewayConnection();
- exposure = gatewayConnnection.getService("exposuretracking",this);
- trace("FLASH: Connected");
- }
- trace("Try to Connect2:");
- var pDirectorToFlashFinished = "no";
- var pGeneral_RS = new Array();
- var pSections_RS = new Array();
- var pSuperSections_RS = new Array();
- var pDownLoads_RS = new Array();
- var pImages_RS = new Array();
- var pFlashpaper_RS = new Array();
- var pSectionViews = new Array();
- var pSectionData = new Array();
- var pDebugResults = "no";
-